I am new to DOORS DXL. I need to add Axes Captions to an existing chart created using DXL. I want to pass a string variable from DXL code into a chart graph within an ActiveWorkBook. I have recorded the following macro in Excel:
Sub Macro1() I am having difficulty in knowing which DXL OLE commands (oleGet, oleMethod, oldPut, etc) to use to add the caption/text. Thank you in advance for any guidance you can provide. sjc2018 - Tue Jan 08 12:14:30 EST 2019 |
Re: Does anyone know if it is possible to set AxisTitle Caption/Text from DXL? The Macro you posted translates roughly to the following in DXL:
OleAutoObj objExcel = oleGetAutoObject("Excel.Application"); //get existing, open excel
OleAutoObj objActiveChart;
oleGet(objExcel, "ActiveChart", objActiveChart);
OleAutoArgs args = create();
put(args, 306); //301 = msoElementPrimaryCategoryAxisTitleAdjacentToAxis
oleMethod(objActiveChart, "SetElement", args);
OleAutoObj objSelection;
oleGet(objExcel, "Selection", objSelection);
olePut(objSelection, "Caption", "Assigned Teams's");
clear(args);
put(args, 306); //306 = msoElementPrimaryValueAxisTitleAdjacentToAxis
oleMethod(objActiveChart, "SetElement", args);
oleGet(objExcel, "Selection", objSelection);
olePut(objSelection, "Caption", "Requirements");
This snipped expects a open Excel document and a selected chart. When testing this I wasnt able to set a text for the y-axis, if I record a macro I get the same you did, but even running the macro in excel itself doesn't add the caption to the y axis for me. Maybe this is a general excel problem and you can find a solution by googling?
Generally speaking you want to use oleGet for "Properties", like the text or height of a cell (or Application.ActiveChart and Application.Selection in the example above). oleMethod is for function calls, like the SetElement function in the example above. Anything that comes with brackets is a function call. Some functions don't need any arguments though, so things like cell.AutoFit is a function call without arguments, that would still need to be done using oleMethod, even though it looks like a property. olePut is for "putting" information into a property, so anything with a equals sign and some value on the right hand side (in the example above the "Selection.Caption = 'Requirements'") If you run into constants in a vba macro (like msoElementPrimaryCategoryAxisTitleAdjacentToAxis), you can rightclick -> QuickInfo them in the VBA code editor to see their numeric value to use in dxl. In VBA you usually end up chaining a lot of commands (e.g. ActiveWorkbook.Sheets("SheetName").Cells(1,10).Value= "Test"), in DXL you have to run them one by one, this is why a single line in VBA can become several lines in DXL, the logic behind the code is generally the same though.
Hope that helps a bit |
Re: Does anyone know if it is possible to set AxisTitle Caption/Text from DXL? O.Wilkop - Wed Jan 09 03:39:35 EST 2019 The Macro you posted translates roughly to the following in DXL:
OleAutoObj objExcel = oleGetAutoObject("Excel.Application"); //get existing, open excel
OleAutoObj objActiveChart;
oleGet(objExcel, "ActiveChart", objActiveChart);
OleAutoArgs args = create();
put(args, 306); //301 = msoElementPrimaryCategoryAxisTitleAdjacentToAxis
oleMethod(objActiveChart, "SetElement", args);
OleAutoObj objSelection;
oleGet(objExcel, "Selection", objSelection);
olePut(objSelection, "Caption", "Assigned Teams's");
clear(args);
put(args, 306); //306 = msoElementPrimaryValueAxisTitleAdjacentToAxis
oleMethod(objActiveChart, "SetElement", args);
oleGet(objExcel, "Selection", objSelection);
olePut(objSelection, "Caption", "Requirements");
This snipped expects a open Excel document and a selected chart. When testing this I wasnt able to set a text for the y-axis, if I record a macro I get the same you did, but even running the macro in excel itself doesn't add the caption to the y axis for me. Maybe this is a general excel problem and you can find a solution by googling?
Generally speaking you want to use oleGet for "Properties", like the text or height of a cell (or Application.ActiveChart and Application.Selection in the example above). oleMethod is for function calls, like the SetElement function in the example above. Anything that comes with brackets is a function call. Some functions don't need any arguments though, so things like cell.AutoFit is a function call without arguments, that would still need to be done using oleMethod, even though it looks like a property. olePut is for "putting" information into a property, so anything with a equals sign and some value on the right hand side (in the example above the "Selection.Caption = 'Requirements'") If you run into constants in a vba macro (like msoElementPrimaryCategoryAxisTitleAdjacentToAxis), you can rightclick -> QuickInfo them in the VBA code editor to see their numeric value to use in dxl. In VBA you usually end up chaining a lot of commands (e.g. ActiveWorkbook.Sheets("SheetName").Cells(1,10).Value= "Test"), in DXL you have to run them one by one, this is why a single line in VBA can become several lines in DXL, the logic behind the code is generally the same though.
Hope that helps a bit
Dear O.Wilkop,
//Note: This displays the Y-Axis Caption/Text "Axis Title"
Thank you also for explaining the differences between oleGet, olePut, and oleMethod. Regards, sjc2018
|